package com.woniu.controller.backpage;

import com.woniu.entity.Depot;
import com.woniu.service.backpage.IDepotService;
import com.woniu.util.RequestParams;
import com.woniu.util.ResData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 仓库表controller层
 * @author 任楷锐
 * @data 2023/3/9 14:59
 */
@RestController
@RequestMapping("/depot")
public class DepotController {
    @Autowired
    private IDepotService depotService;

    //查询所有仓库信息
    @RequestMapping("/getAllDepot")
    public ResData<?> getAllDepot(@RequestBody RequestParams<Depot> requestParams){
        ResData<?> allDepot = depotService.getAllDepot(requestParams);
        return allDepot;
    }

    //查询所有区域信息
    @RequestMapping("/getAllRegion")
    public ResData<?> getAllRegion(){
        ResData<?> allRegion = depotService.getAllRegion();
        return allRegion;
    }


    //根据id查询一条仓库的信息
    @RequestMapping("/getDepotById")
    public ResData<?> getDepotById(Integer id){
        ResData<?> depotById = depotService.getDepotById(id);
        return depotById;
    }


    //新增仓库
    @RequestMapping("/insertDepot")
    public ResData<?> insertDepot(@RequestBody Depot depot){
       return depotService.insertDepot(depot);
    }
}
